<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

	var xhr = null;
	function getXMLHttpRequest() {
		if (window.ActiveXObject) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e1) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e2) {
					return null;
				}
			}
		} else if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else {
			return null;
		}
	}

	function requestHello(URL) {
		param = f.name.value;
		URL = URL + "?name=" + encodeURIComponent(param);
		xhr = getXMLHttpRequest();
		xhr.onreadystatechange = responseHello;
		xhr.open("GET", URL, true);
		xhr.send(null);
	}
	
	function responseHello(){
		if(xhr.readyState == 4){
			var str = xhr.responseText;
			document.getElementById("message").innerHTML = str;
		}else{
			alert(!"Fail : "+httpRequest.status);
		}
	}
</script>
</head>
<body>
<form name="f">
<input type="text" name="name">
<input type="button" value="입력 " onclick="requestHello('hello.jsp')">
</form>
<div id="message"></div>

</body>
</html>